#*************************
# 声明cmake最低的版本号
#************************
cmake_minimum_required(VERSION 3.16)

#*************************
# 项目名称
#************************
project(serialNetTools)

#*************************
# 设置编译类型
#************************
# set(DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Release")
endif()

#*************************
# 指定C++标准 
#************************
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # 确保编译器支持所选标准

#************************
# 设置优化等级
#************************
set(CMAKE_CXX_FLAGS "-w")# 忽略警告信息
set(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb ${CMAKE_CXX_FLAGS}")# 设置DEBUG模式的编译选项
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g -ggdb ${CMAKE_CXX_FLAGS}")# 设置RELEASE模式的编译选项


# set(VAL "a")    	# VAL 内容为 1 个值：a
# set(VAL "a" b)  	# VAL 内容为 2 个值：a;b
# set(VAL a;b)    	# VAL 内容为 2 个值：a;b
# set(VAL a;b c)  	# VAL 内容为 3 个值：a;b;c

# message(STATUS "VAL = ${VAL}")

message(STATUS "PROJECT_NAME = ${PROJECT_NAME}")


#*************************
# 添加头文件
#************************
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}")

#*************************
# 生成动态库
#************************
add_library(${PROJECT_NAME} SHARED serialNetTools.cpp)
add_library(${PROJECT_NAME}_static STATIC serialNetTools.cpp)
# target_link_libraries(${PROJECT_NAME}_test ${PROJECT_NAME})


#*************************
# 生成可执行文件
#************************
# add_executable(${PROJECT_NAME}_test main_test.cpp serialNetTools.cpp)
add_executable(${PROJECT_NAME}_test main_test.cpp)

# target_link_libraries(${PROJECT_NAME}_test ${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME}_test ${PROJECT_NAME}_static)
